#include "ZeroAttack.h"
#include "Player.h"
#include "RenderManager.h"
#include "CollisionTypes.h"

ZeroAttack::ZeroAttack(Player* player, const sf::FloatRect& collisionBox, const sf::Vector2f& offset, int damage) : _player(player), _cb(collisionBox), _offset(offset), _damage(damage)
{
	_ct.push_back(CT_PLAYER_ATTACK);
	_mf.push_back(CT_ENEMY);
	_component |= COMPONENT_COLLIDEABLE;
	_component |= COMPONENT_DRAWABLE;
	_killMe = false;
	_type = "ZeroAttack";
	setFlag(GHOST);
	removeFlag(GRAVITY_AFFECTED);
}


ZeroAttack::~ZeroAttack(void){}

void ZeroAttack::initialize()
{

}

void ZeroAttack::clean()
{

}

void ZeroAttack::move()
{

}

void ZeroAttack::update()
{
	_origin = sf::Vector2f(_cb.width * 0.5f, _cb.height * 0.5f);
	_cb.left = _player->_position.x;
	_cb.top = _player->_position.y;
}

sf::FloatRect ZeroAttack::collisionBox(int type)
{
	return sf::FloatRect((_cb.left - _origin.x) + _offset.x, (_cb.top - _origin.y) + _offset.y, _cb.width, _cb.height);
}

void ZeroAttack::draw(RenderManager* rm)
{
	sf::RectangleShape rectc(sf::Vector2f(collisionBox().width, collisionBox().height));
	rectc.setPosition(collisionBox().left, collisionBox().top);
	rectc.setFillColor(sf::Color(255, 255, 255, 100));
	rm->draw(rectc);
}

void ZeroAttack::kill()
{
	_killMe = true;
}